﻿using System.Collections.Generic;
using System.Xml.Serialization;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    public abstract class ModelBase 
    {
        private Dictionary<string, bool> _fieldModified = new Dictionary<string,bool>();

        protected void Modified(string fieldName)
        {
            if (!this._fieldModified.ContainsKey(fieldName))
                this._fieldModified.Add(fieldName, true);
            else
                this._fieldModified[fieldName] = true;
        }

        protected void Unmodified(string fieldName)
        {
            if (!this._fieldModified.ContainsKey(fieldName))
                this._fieldModified.Add(fieldName, false);
            else
                this._fieldModified[fieldName] = false;
        }

        protected bool IsModified(string fieldName)
        {
            if (!this._fieldModified.ContainsKey(fieldName))
                return false;
            
            return this._fieldModified[fieldName];
        }

        /// <remarks/>
        [XmlElement(ElementName = "id")]
        public int Id { get; set; }

        public bool IdSpecified { get { return true; } }
    }
}